'''
Created on Nov 19, 2010

@author: namikata
'''

class Keyboard(object):
    '''
    classdocs
    '''

    last_pressed = {}
    current_pressed = {}
    
    def get_key(self,key):
        """0 = not pressed, 1 = pressed, 2 = hold """
        state = 0
        if key in self.current_pressed and self.current_pressed[key]:
            state+=1
            if key in self.last_pressed and self.last_pressed[key]:
                state+=1
        return state
        
    def update(self,pressed_keys):
        self.last_pressed = self.current_pressed
        self.current_pressed = dict(pressed_keys)
